import request from '@/utils/request'

// StoreHouse 新建仓库
export function financeSupplierSave(data) {
  return request({
    url: 'FinanceSupplier/saveOrUpdate',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
// 获取列表信息
export function financeSupplierIndex(data) {
  return request({
    url: 'FinanceSupplier/queryPageList',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

// finance供应商 详情
export function financeSupplierRead(data) {
  return request({
    url: 'FinanceSupplier/queryById',
    method: 'post',
    data: data
  })
}
// 删除
export function financeSupplierDelete(data) {
  return request({
    url: 'FinanceSupplier/deleteByIds',
    method: 'post',
    data: data
  })
}

/**
 * 产品导出
 * @param {*} data
 * product_id 产品ID
 */
export function financeSupplierExcelExport(data) {
  return request({
    url: 'FinanceSupplier/batchExportExcel',
    method: 'post',
    data: data,
    responseType: 'blob'
  })
}

export function financeSupplierExcelAllExport(data) {
  return request({
    url: 'FinanceSupplier/allExportExcel',
    method: 'post',
    data: data,
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 产品导入
 * @param {*} data
 *
 */
export function financeSupplierExcelImport(data) {
  var param = new FormData()
  Object.keys(data).forEach(key => {
    param.append(key, data[key])
  })
  return request({
    url: 'FinanceSupplier/uploadExcel',
    method: 'post',
    data: param,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

/**
 * 产品导入模板下载
 * @param {*} data
 *
 */
export const financeExcelDownloadURL = process.env.BASE_API + 'FinanceSupplier/downloadExcel'
export function financeDownloadExcelAPI(data) {
  return request({
    url: 'FinanceSupplier/downloadExcel',
    method: 'post',
    data: data,
    responseType: 'blob'
  })
}
